[Top] [Prev] [Next] [Bottom]
[Contents]
SaHexToAscii
Converts a binary buffer to a null terminated ascii character representation.
#include "WorkingDialog.h"
void *SaHexToAscii(void *vp, int siz, int prepend);
Arguments
- vp
- Pointer to a buffer of binary data.
- siz
- The size, in bytes, of the binary buffer.
- prepend
- Indicates if a "0x" prefix is desired on the converted string data. A value of 1 indicates the user should prepend the returned value with "0x", and 0 means don't prepend.
Return Values
A pointer to a null terminated string that represents the binary data, or NULL on failure. Note: This string must be free'd to avoid memory leaks.
SaHexToAscii will return a string of length 2 x siz if prepend is 0, or 2 x siz + 2 if prepend is 1.
Returned values are `0' - `9' and `a', `b', `c', `d', `e', or `f'.
Failures occur if malloc fails, or a NULL buffer is passed in for conversion.
#include "WorkingDialog.h"
...
#define SIZE 1024
void *binary; /* pointer for binary data */
char *string; /* conversion string */
if(!(binary = malloc(1024)))
return;
read(file_descriptor, binary, SIZE);
if((string = SaHexToAscii(binary, size, 0)) == NULL) {
free(binary);
return;
}
printf("Ascii Data: %s\n", string);
...
See Also
[Top] [Prev] [Next] [Bottom]
[Contents]
info@bluestone.com
Copyright © 1997, Bluestone. All rights
reserved.